import { DataTypes, Model } from "sequelize";
import sequelize from "../sequelize";

interface IEdu {
    name: string;
    address: string;
    startDate: string;
    endDate: string;
}

interface IContact {
    emails: string[];
    phones: string[];
    vk: string;
    telegram: string;
    github: string;
}

export class Student extends Model {
    declare id: number;
    declare email: string;
    declare firstName: string;
    declare lastName: string;
    declare patronymic: string;
    declare photo: string;
    declare birthDate: string;
    declare aboutMe: string;
    declare sex?: 1 | 2; //1 - женский а 2 - мужской
    declare password: string;
    declare score: number;
    declare isVerified: boolean;
    declare personalities16: string;
    declare isLazy: boolean;
    declare isAlcoholic: boolean;
    declare status: string;
    declare skills: string[];
    declare contacts: IContact[];
    declare professionalRole: string;
    declare mainEdu: IEdu[];
    declare extraEdu: IEdu[];
}

Student.init(
    {
        id: {
            type: DataTypes.INTEGER,
            allowNull: false,
            primaryKey: true,
            autoIncrement: true,
            unique: true,
        },
        email: {
            type: DataTypes.STRING,
            unique: true,
        },
        firstName: {
            type: DataTypes.STRING,
            allowNull: false,
        },
        lastName: {
            type: DataTypes.STRING,
            allowNull: false,
        },
        patronymic: {
            type: DataTypes.STRING,
            allowNull: false,
        },
        sex: {
            type: DataTypes.INTEGER,
        },
        photo: {
            type: DataTypes.STRING,
        },
        aboutMe: {
            type: DataTypes.STRING,
        },
        address: {
            type: DataTypes.STRING,
        },
        birthDate: {
            type: DataTypes.STRING,
        },
        password: {
            type: DataTypes.STRING,
            allowNull: false,
        },
        score: {
            type: DataTypes.INTEGER,
            defaultValue: 0,
        },
        skills: {
            type: DataTypes.JSONB,
            defaultValue: [],
        },
        professionalRole: {
            type: DataTypes.STRING,
        },
        mainEdu: {
            type: DataTypes.JSONB,
            defaultValue: [],
        },
        extraEdu: {
            type: DataTypes.JSONB,
            defaultValue: [],
        },
        qualification: {
            type: DataTypes.STRING,
        },
        contacts: {
            type: DataTypes.JSONB,
            defaultValue: {
                phones: [],
                emails: [],
                vk: null,
                telegram: null,
                github: null,
            },
        },
        personalities16: { type: DataTypes.STRING },
        isVerified: {
            type: DataTypes.BOOLEAN,
            defaultValue: false,
        },
        isReadyRemote: {
            type: DataTypes.BOOLEAN,
            defaultValue: false,
        },
        isReadyRelocation: {
            type: DataTypes.BOOLEAN,
            defaultValue: false,
        },
        isLazy: {
            type: DataTypes.BOOLEAN,
            defaultValue: false,
        },
        isAlcoholic: {
            type: DataTypes.BOOLEAN,
            defaultValue: false,
        },
        status: {
            type: DataTypes.STRING,
        },
    },
    {
        tableName: "students",
        sequelize,
    }
);
